package router

import (
	"IMChat/controller"
	"IMChat/middlewares"
	"IMChat/service"

	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	router := gin.Default()
	auth := router.Group("/u", middlewares.AuthCheck())

	router.POST("/user/login", service.Login)
	router.POST("/user/register", service.Register)
	router.POST("/send/code", service.SendCode)
	auth.GET("/user/detail", service.GetUserDetail)
	auth.GET("/websocket/message", service.WebSocketMessage)
	auth.GET("/chat/list", service.ChatList)
	auth.GET("/user/profile", service.UserProfile)
	auth.POST("/user/add", service.UserAdd)
	auth.DELETE("/user/delete", service.UserDelete)

	router.Static("/public/resource", "./public/resource")
	router.LoadHTMLGlob("tempaltes/**/*")
	router.GET("/admin/login.html", controller.HomeLogin)
	router.GET("/home.html", controller.HomeIn)

	router.GET("/test", controller.Test)
	return router
}
